home *** CD-ROM | disk | FTP | other *** search
/ Champak 128 / Vol 128 (Damaged).iso / games / boiler_b.swf / scripts / DefineSprite_215 / frame_1 / DoAction.as
Encoding:
Text File  |  2011-03-26  |  1.2 KB  |  66 lines

  1. var pState;
  2. var pX;
  3. var pY;
  4. var pNum;
  5. var pTimer;
  6. this.setPos = function(ty)
  7. {
  8.    var _loc1_ = this;
  9.    _loc1_._x = pX + 38;
  10.    _loc1_._y = pY - ty;
  11.    if(pTimer > 0)
  12.    {
  13.       pTimer--;
  14.    }
  15.    else if(pTimer == 0)
  16.    {
  17.       _loc1_.activate();
  18.       pTimer = -1;
  19.    }
  20. };
  21. this.activate = function()
  22. {
  23.    var _loc1_ = this;
  24.    var _loc2_ = Math.floor(Math.random() * 4);
  25.    switch(_loc2_)
  26.    {
  27.       case 0:
  28.          _loc1_.setUp(9,13);
  29.          break;
  30.       case 1:
  31.          _loc1_.setUp(20,32);
  32.          break;
  33.       case 2:
  34.          _loc1_.setUp(35,69);
  35.          break;
  36.       case 3:
  37.          _loc1_.setUp(18,84);
  38.    }
  39.    _loc1_.pState = "active";
  40.    _loc1_.gotoAndPlay(5);
  41. };
  42. this.collect = function()
  43. {
  44.    var _loc1_ = this;
  45.    _loc1_.pState = "collected";
  46.    _loc1_._parent.snd_mc.playsound("pMug");
  47.    _loc1_._parent.top_mc.increaseEnergy(30);
  48.    _loc1_._parent.top_mc.addScore(2000);
  49.    _loc1_.pX = -1000;
  50.    _loc1_.gotoAndStop(2);
  51.    _loc1_.pTimer = 240;
  52. };
  53. this.hideMe = function()
  54. {
  55.    var _loc1_ = this;
  56.    _loc1_.pX = -1000;
  57.    _loc1_.gotoAndStop(2);
  58.    _loc1_.pTimer = 240;
  59. };
  60. this.setUp = function(x, y)
  61. {
  62.    this.pX = x * 16;
  63.    this.pY = y * 16;
  64. };
  65. this.activate();
  66.